'''
LoginPage页面对象，主要用于实现web系统的登录操作

'''

from base.base_page import BasePage
import selenium.webdriver as webdriver
from selenium.webdriver import chrome
from selenium.webdriver.common.by import By
import time

#登录页面对象
class LoginPage(BasePage):
    # 页面URL

    url = 'http://39.98.138.157/shopxo/index.php?s=/index/user/logininfo.html'
    print('login:' + url)

    # 页面关键元素
    user = (By.NAME,'accounts')
    # 18555059369
    pwd = (By.NAME,'pwd')
    #238200
    button = (By.XPATH,'/html/body/div[4]/div/div[2]/div[2]/form/div[3]/button')

    # 页面的业务流程
    def login(self, U, p):
        self.visit(self.url)
        self.input(self.user,U)
        self.input(self.pwd,p)
        self.click(self.button)

if __name__ == '__main__':
    print('start...')
    driver = webdriver.Chrome()
    lp = LoginPage(driver)
    res = lp.login('666666','111111')
    print('tttt')
    print('res')
    lp.snapshot('a.png')
    lp.quit()
